using WMS.RealTime.IServers.Interfaces;
using WMS.RealTime.Domain.DTOs;
using Microsoft.Extensions.Logging;

namespace WMS.RealTime.Servers.Services
{
    /// <summary>
    /// 大屏数据服务实现
    /// </summary>
    public class DashboardDataService : IDashboardDataService
    {
        private readonly ILogger<DashboardDataService> _logger;
        private readonly IWMSDataService _wmsDataService;

        public DashboardDataService(
            ILogger<DashboardDataService> logger,
            IWMSDataService wmsDataService)
        {
            _logger = logger;
            _wmsDataService = wmsDataService;
        }

        /// <summary>
        /// 获取今日概况
        /// </summary>
        public async Task<DailyOverview> GetTodayOverviewAsync()
        {
            _logger.LogInformation("获取今日概况数据");
            return await _wmsDataService.GetTodayOverviewAsync();
        }

        /// <summary>
        /// 获取昨日概况
        /// </summary>
        public async Task<DailyOverview> GetYesterdayOverviewAsync()
        {
            _logger.LogInformation("获取昨日概况数据");
            return await _wmsDataService.GetYesterdayOverviewAsync();
        }

        /// <summary>
        /// 获取库存占比
        /// </summary>
        public async Task<InventoryProportion> GetInventoryProportionAsync()
        {
            _logger.LogInformation("获取库存占比数据");
            return await _wmsDataService.GetInventoryProportionAsync();
        }

        /// <summary>
        /// 获取入库统计
        /// </summary>
        public async Task<InboundStatistics> GetInboundStatisticsAsync(string timeRange = "7")
        {
            _logger.LogInformation($"获取入库统计数据，时间范围：{timeRange}");
            return await _wmsDataService.GetInboundStatisticsAsync(timeRange);
        }

        /// <summary>
        /// 获取待办事项
        /// </summary>
        public async Task<TodoItems> GetTodoItemsAsync()
        {
            _logger.LogInformation("获取待办事项数据");
            return await _wmsDataService.GetTodoItemsAsync();
        }

        /// <summary>
        /// 获取告警数据
        /// </summary>
        public async Task<AlertData> GetAlertDataAsync()
        {
            _logger.LogInformation("获取告警数据");
            return await _wmsDataService.GetAlertDataAsync();
        }

        /// <summary>
        /// 获取排名数据
        /// </summary>
        public async Task<RankingData> GetRankingDataAsync()
        {
            _logger.LogInformation("获取排名数据");
            return await _wmsDataService.GetRankingDataAsync();
        }

        /// <summary>
        /// 获取系统消息
        /// </summary>
        public async Task<List<string>> GetSystemMessagesAsync(int count = 10)
        {
            _logger.LogInformation($"获取系统消息，数量：{count}");
            return await _wmsDataService.GetSystemMessagesAsync(count);
        }
    }
} 